fetch("http://chst.vip:1234/api/getcategorytitle")
    .then(body => body.json())
    .then(res => {
        console.log(res);
        let html = "";
        res.result.forEach(item => {
            html +=
                `
        <li class="a${item.titleId}"">
        <div class="biaoti"><h4>${item.title}<span>▼</span></h4></div>
        <div class="chouti"></div>
        </li>
        `
            let ul = document.querySelector("#main ul")
            ul.innerHTML = html
            xiala(item.titleId)
        })
    })

function xiala(titleId) {
    console.log(titleId);
fetch("http://chst.vip:1234/api/getcategory?titleid=" + titleId)
        .then(body => body.json())
        .then(res => {
            console.log(res);
            let html = "";
            res.result.forEach(item => {
                html +=
                    `
        <div class=""><a href="../page/bijia.html?categoryid=${item.categoryId}">${item.category}</a></div>
        `
            })
            let htmll = document.querySelectorAll("#main ul li .chouti")
            console.log(htmll);
            htmll[titleId].innerHTML += html
        })



}

let dianji = document.querySelector("#main ul")
$("#main ul").on("click", function (e) {
    console.log(e.target);
    // $("#main ul li>.chouti").css({
    //     display: "none"
    // })
    $(e.target).parent().next().slideToggle(200)

    // dianji.parentNode.nextElementSibling.style.display="block"
})

    // let a = e.target
    // console.log(a);
    // a.parentNode.nextElementSibling.style.display="block"
